//
//  TextFileld.m
//  Recipe
//
//  Created by YaSha_Tom on 2018/12/17.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "TextFileld.h"
#import <Masonry.h>

@implementation TextFileld

- (void)setImageName:(NSString *)imageName placeholder:(NSString *)placeholder {
    self.clearButtonMode = UITextFieldViewModeWhileEditing;
    self.contentMode =UIViewContentModeCenter;
    self.placeholder = placeholder;
    self.font = [UIFont systemFontOfSize:14];
    self.text = @"";
    
    
    UIView *backView = [[UIView alloc] init];
    [backView setFrame:CGRectMake(0, 0, 45, 45)];
    [backView setBackgroundColor:[UIColor clearColor]];
    
    UIImageView *icon = [[UIImageView alloc] init];
    [icon setImage:[UIImage imageNamed:imageName]];
    [backView addSubview:icon];
    [icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(16, 16));
        make.centerX.centerY.mas_equalTo(backView);
    }];
    
    [self setLeftView:backView];
    [self setLeftViewMode:UITextFieldViewModeAlways];
    
    UILabel *linelabel = [[UILabel alloc] initWithFrame:CGRects(0, 45, 325, 1)];
    self.lineLb = linelabel;
    linelabel.backgroundColor = [UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:1.00];
    [self addSubview:linelabel];
}

@end
